// PDMSClassRegister.cpp: implementation of the PDMSClassRegister class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PDMSClassRegister.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace PDMS
{
	namespace PDMSFrame
	{
		
		PDMSClassRegisterInfo::PDMSClassRegisterInfo(const UE_PDMSCLASS_REGKEY_TYPE& key, 
			const StdString& strStyleName, UeDbObject* (*pCreateObject)()):
			RegisterInfo< UE_PDMSCLASS_REGKEY_TYPE, UeDbObject* >( key, strStyleName, pCreateObject )
		{
			PDMSClassRegister::Instance()->Register( key, this );
		}

		PDMSClassRegisterInfo::~PDMSClassRegisterInfo()
		{
			PDMSClassRegister::Instance()->Remove( this->GetKey() );
		}


		IMPLEMENT_SINGLETON( PDMSClassRegister );
		
		PDMSClassRegister::PDMSClassRegister()
		{
			
		}
		
		PDMSClassRegister::~PDMSClassRegister()
		{
			
		}

		BOOL PDMSClassRegister::HasClass( const UE_PDMSCLASS_REGKEY_TYPE& strClassName )
		{
			PDMSClassRegisterInfo* pInfo = NULL;
			
			return FindInfo( strClassName, pInfo );
		}

		UeDbObject* PDMSClassRegister::CreateObject( const UE_PDMSCLASS_REGKEY_TYPE& strClassName )
		{
			PDMSClassRegisterInfo* pInfo = NULL;

			if ( FindInfo( strClassName, pInfo ) )
			{
				return pInfo->CreateObject();
			}
			return NULL;
		}
	}
}